package interactiond

import (
	"time"

	cinteractiond "gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/interactiond"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/ddd"
)

// @collname 评论集合(i_replay)
type collReplay struct {
	ReplayID     string                `bson:"_id" `
	Context      string                `bson:"context"`      // 评论内容
	Status       cinteractiond.RStatus `bson:"status"`       // 状态
	IGID         string                `bson:"igid"`         //互动组ID
	ParentID     string                `bson:"parentID"`     //上级评论ID 填写时为1级评论
	LastTime     time.Time             `bson:"lastTime"`     //子评论最后评论时间
	LastReplayer string                `bson:"lastReplayer"` //子评论最后评论人
	ReplayNum    int                   `bson:"replayNum"`    //子评论数量
	LikeNum      int                   `bson:"likeNum"`      // 评论点赞数量
	Checker      string                `bson:"checker"`      //审核人
	ChkTime      time.Time             `bson:"chkTime"`      //审核时间
	ChkContet    string                `bson:"chkContet"`    //审核意见
	ChkResult    bool                  `bson:"chkResult"`    //审核结果
	Creator      string                `bson:"creator"`      //创建人
	CreTime      time.Time             `bson:"creTime"`      //创建时间
	DeleteTime   time.Time             `bson:"deleteTime"`   //删除时间
	Deleter      string                `bson:"deleter"`      //删除人

}

func (c collReplay) CollID() string {
	return c.ReplayID
}
func (collReplay) CollName() string {
	return collNameReplay
}
func (c collReplay) IsCache() bool {
	return c.ReplayID != "" && c.Status >= 0
}
func (c *collReplay) FullDesc(e cinteractiond.ReplayDesc) {
	c.Context = e.Context
	c.Status = e.Status

}
func (c collReplay) ToDesc() cinteractiond.ReplayDesc {
	return cinteractiond.ReplayDesc{
		Context: c.Context,
		Status:  c.Status,
	}
}

func (c *collReplay) FullPath(e cinteractiond.ReplayPath) {
	c.IGID = e.IGID
	c.ParentID = e.ParentID

}
func (c collReplay) ToPath() cinteractiond.ReplayPath {
	return cinteractiond.ReplayPath{
		IGID:     c.IGID,
		ParentID: c.ParentID,
	}
}

func (c *collReplay) FullTotal(e cinteractiond.ChildReplyTotal) {
	c.LastTime = e.LastTime
	c.LastReplayer = e.LastReplayer
	c.ReplayNum = e.ReplayNum
	c.LikeNum = e.LikeNum

}
func (c collReplay) ToTotal() cinteractiond.ChildReplyTotal {
	return cinteractiond.ChildReplyTotal{
		LastTime:     c.LastTime,
		LastReplayer: c.LastReplayer,
		ReplayNum:    c.ReplayNum,
		LikeNum:      c.LikeNum,
	}
}

func (c *collReplay) FullCheck(e cinteractiond.ReplayCheck) {
	c.Checker = e.Checker
	c.ChkTime = e.ChkTime
	c.ChkContet = e.ChkContet
	c.ChkResult = e.ChkResult

}
func (c collReplay) ToCheck() cinteractiond.ReplayCheck {
	return cinteractiond.ReplayCheck{
		Checker:   c.Checker,
		ChkTime:   c.ChkTime,
		ChkContet: c.ChkContet,
		ChkResult: c.ChkResult,
	}
}

func (c *collReplay) FullOperator(e cinteractiond.Operator) {
	c.Creator = e.Creator
	c.CreTime = e.CreTime
	c.DeleteTime = e.DeleteTime
	c.Deleter = e.Deleter

}
func (c collReplay) ToOperator() cinteractiond.Operator {
	return cinteractiond.Operator{
		Creator:    c.Creator,
		CreTime:    c.CreTime,
		DeleteTime: c.DeleteTime,
		Deleter:    c.Deleter,
	}
}

func (c collReplay) ToAggregate() ddd.Aggregate {
	return c.ToReplayAggregate()
}
func (c collReplay) ToReplayAggregate() *cinteractiond.ReplayAggregate {
	return &cinteractiond.ReplayAggregate{
		ReplayID:        c.ReplayID,
		ReplayDesc:      c.ToDesc(),
		ReplayPath:      c.ToPath(),
		ChildReplyTotal: c.ToTotal(),
		ReplayCheck:     c.ToCheck(),
		Operator:        c.ToOperator(),
	}
}
